from flask import Flask
from concurrent.futures import ThreadPoolExecutor
import subprocess
app = Flask(__name__)

executor = ThreadPoolExecutor()


def deploy():
    subprocess.run(["git", "pull"], stdout=open("deploy.log", "a"))
    subprocess.run(["sh", "restart.sh"], stdout=open("deploy.log", "a"))


@app.route('/deploy/', methods=["POST"])
def index():
    executor.submit(deploy)
    return "Hello World"


if __name__ == "__main__":
    app.run()
